/**
 * 类
 */
class Greeter {
  greeting:string; //greeting 为成员
  constructor (message:string){
    this.greeting = message;
  }
  greet(){
    return "Hello," + this.greeting;
  }
}
let greeterd = new Greeter("World");

/**
 * 继承
 */
class Animal {
  name:string;
  constructor(thisName:string) {
    this.name = thisName
  }
  move (distanceInMeters:number = 1) {
    console.log(`Aninal moved ${distanceInMeters}M`);  }
}
class Dog extends Animal {
  bark () {
    console.log("Woof Woof");
  }
}
const dog = new Dog ("Bob");
dog.bark();
dog.move(3);

class Snake extends Animal {
  constructor (name:string) {
    super(name);
  }
  move(distanceInMeters = 6) {
    console.log("Slithering...");
    super.move(distanceInMeters)
  }
}
class Horse extends Animal {
  constructor(name:string) {
    super(name);
  }
  move(distanceInMeters = 40) {
    console.log("Galloping...");
    super.move(distanceInMeters)
  }
}

let sam = new Snake("Sammy the Python");
let tom:Animal = new Horse("Tommy the Palomino");
sam.move()
tom.move(55)

